package br.com.conhecimento.util;

import java.io.IOException;

import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

import com.sun.faces.context.SessionMap;

/**
 * Responsavel por acoes do FacesContext
 * 
 * @author Luis Garcia
 * @since 27/04/2013
 */
public class FacesUtil {

    public static SessionMap getSessionMap() {
        return (SessionMap) FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
    }
    
    public static void redirectPage(String page) throws IOException {
    	ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
    	context.redirect(context.getRequestContextPath()+page);
    }
    
    public static void addMsg(FacesMessage.Severity severity,String title, String msg) {  
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, title, msg));  
    }  
    
}